To export a code to C# NUnit, you need to:
1. Get the test code in C# NUnit language
2. Integrate Silk Mobile and Visual studio.
Following is a step-by-step description of how to do it.
Step 1: Export test code in C# NUnit.
Step 2: Once created a script, select ‘Code’ tab in the main window
Step 3: Then choose “C# NUnit”.
Step 4:
Then click on ‘Copy to Clipboard’ icon
The generated code has been copied to the clipboard of your system.
Step 5: Now paste the code to the NUnit testing environment you are using.
Following is an example of such an exported code:
using System;using System.Text;using NUnit.Framework;using experitestClient;namespace Experitest{ [TestFixture] public class ShlomoTest1 { private string host = "localhost"; private int port = 8889; private string projectBaseDirectory = "C:\\Users\\Dell\\workspace\\project18"; protected Client client = null; [SetUp] public void SetupTest() { client = new Client(host, port, true); client.SetProjectBaseDirectory(projectBaseDirectory); client.SetReporter("xml", "reports", "ShlomoTest1"); } [Test] public void TestShlomoTest1() { client.SetDevice("adb:Xiaomi MI 3W"); client.Launch("com.experitest.ExperiBank/.LoginActivity", true, true); client.ElementSendText("NATIVE", "xpath=//*[@hint='Username']", 0, "company"); client.ElementSendText("NATIVE", "xpath=//*[@hint='Password']", 0, "company"); client.Click("NATIVE", "xpath=//*[@text='Login']", 0, 1); } [TearDown] public void TearDown() { // Generates a report of the test case. // For more information - http://supportline.microfocus.com/Documentation/books/ASQ/SilkMobile/90/help/Report+Of+Executed+Test client.GenerateReport(false); // Releases the client so that other clients can approach the agent in the near future. client.ReleaseClient(); } }}
Step 6:
Integrate to Visual Studio C# Environment:
To integrate the script into Visual Studio you need to integrate Silk Mobile using the built-in .dll files which are located in the client folder in your installation directory(.../clients/C#).
Following are the required .dll files:
CookComputing.XmlRpcV2.dll
imageClient.dll
Step 7:
In order to run NUnit tests you will need to download and install NUnit framework from http://nunit.org/ .
Step 8:
After installation is complete, you will need to add reference to the nunit.framework.dll file.
The file can be located under the NUnit installation directory, for example:
< ...\NUnit 2.6.4\bin\framework >